package com.movitech.mobile.cz.base.purchase.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.movitech.mobile.cz.base.common.license.LicenseUtil;
import com.movitech.mobile.cz.base.common.util.StringUtils;
import com.movitech.mobile.cz.base.purchase.entity.WFlowSubForm;
import com.movitech.mobile.cz.base.purchase.mapper.WFlowSubFormMapper;
import com.movitech.mobile.cz.base.purchase.service.WFlowSubFormService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 流程表单子表 服务实现类
 * </p>
 *
 * @author Movitech Mobile
 * @since 2018-04-16
 */
@Service
public class WFlowSubFormServiceImpl extends ServiceImpl<WFlowSubFormMapper, WFlowSubForm> implements WFlowSubFormService {

    @Override
    public boolean updateByFormId(WFlowSubForm wFlowSubForm) {
        LicenseUtil.INSTANCE.validate();
        if(StringUtils.isEmpty(wFlowSubForm.getFlowFormId()))
            return false;
        EntityWrapper entityWrapper = new EntityWrapper();
        WFlowSubForm where = new WFlowSubForm();
        where.setFlowFormId(wFlowSubForm.getFlowFormId());
        entityWrapper.setEntity(where);
        return update(wFlowSubForm,entityWrapper);
    }

    @Override
    public WFlowSubForm selectByFormId(String formId) {
        LicenseUtil.INSTANCE.validate();
        return selectOne(new EntityWrapper<WFlowSubForm>().eq("flow_form_id",formId));


    }
}
